|
Cytosim
PI
Cytoskeleton Simulator
|
This class is similar to STL::dequeue<OBJ> and the naming of the functions is consistent with STL whenever possible.
NodeList has pointers to the first and last elements of the list. The List also keeps track of how many objects are linked. Functions are given to link and unlink Nodes in constant time.
A function mix() randomize the order of the Nodes in the list. Such randomization are necessary in the simulation to avoid any bias which could derive from a fixed ordering.
The list is zero-terminated on both sides, and it can be traversed in either ways: for ( Node * n = first(); n ; n = n->next() ); for ( Node * n = last(); n ; n = n->prev() );
Public Member Functions | |
| NodeList () | |
| Constructor. | |
| NodeList (ObjectSet *s) | |
| Constructor. | |
| virtual | ~NodeList () |
| Destructor. | |
| Node * | first () const |
| First Node. | |
| Node * | last () const |
| First Node. | |
| unsigned int | size () const |
| Number of objects in the list. | |
| bool | empty () const |
| true if no element | |
| ObjectSet * | objset () const |
| return associated ObjectSet | |
| void | push_front (Node *) |
| put Node first in the list | |
| void | push_back (Node *) |
| put Node last in the list | |
| void | transfer (NodeList &list) |
| import all objects from given list, and empty it | |
| void | push_after (Node *p, Node *np) |
| put new Node np after existing one p | |
| void | push_before (Node *p, Node *np) |
| put new Node np before existing one p | |
| void | pop (Node *op) |
| Remove Node op from the list. | |
| Node * | pop_front () |
| Remove Node op from the list. | |
| virtual void | clear () |
| clear the list by calling pop(first) until empty | |
| virtual void | erase () |
| clear the list as above, calling delete( ) for each node | |
| void | swap (Node *p) |
| Rearrange (first–P-Pnext–last) as (Pnext–last-first–P) More... | |
| void | shuffle1 (Node *p, Node *q) |
| Rearrange (first–P-Pnext–Qprev-Q–last) as (Pnext–Qprev-first–P-Q–last) More... | |
| void | shuffle2 (Node *p, Node *q) |
| Rearrange (first–P-Pnext–Qprev-Q–last) as (first–P-Q–last-Pnext–Qprev) More... | |
| void | mix (Random &) |
| Mix using swap() and shuffle() functions. | |
| void | mix5 (Random &) |
| call mix() five times | |
| int | bad () const |
| test coherence of list | |
Protected Attributes | |
| ObjectSet * | nSet |
| Pointer to embedding ObjectSet. | |
Rearrange (first–P-Pnext–Qprev-Q–last) as (Pnext–Qprev-first–P-Q–last)
If q is between nFirst and p, this will destroy the list, but there is no way to check such condition here.
Rearrange (first–P-Pnext–Qprev-Q–last) as (first–P-Q–last-Pnext–Qprev)
If q is between nFirst and p, this will destroy the list, but there is no way to check such condition here.
| void swap | ( | Node * | p | ) |
Rearrange (first–P-Pnext–last) as (Pnext–last-first–P)